package lxs.swift.collector.tuple;

import java.util.Objects;

public class Tuple2<T1, T2> implements Tuple {
    public T1 _1;
    public T2 _2;

    protected Tuple2() {
    }

    protected Tuple2(final T1 _1, final T2 _2) {
        this._1 = _1;
        this._2 = _2;
    }

    @Override
    public Object[] toArray() {
        return new Object[]{_1, _2};
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Tuple2<?, ?> other = (Tuple2<?, ?>) o;
        return Objects.equals(_1, other._1) && Objects.equals(_2, other._2);
    }

    @Override
    public int hashCode() {
        return Objects.hash(_1, _2);
    }

    @Override
    public String toString() {
        return "Tuple(" + _1 + ", " + _2 + ')';
    }

}
